﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Smallerp.Contracts.DataContracts
{
    [DataContract]
    public class OrderViewDCT
    {
        #region 私有字段
        private int _orderProductId;
        private string _orderName;
        private DateTime _startTime;
        private DateTime _completeTime;
        private int _status;
        private string _orderPath;
        private string _remark;
        private int _productNum;
        private int _priority;
        private int _sameFlagOrderId;

        [DataMember]
        public List<PhotoDCT> PhotoS { get; set; }//相应的照片信息 
        [DataMember]
        public int PhotoCount
        {
            get
            {
                if (PhotoS != null)
                    return PhotoS.Count;
                else
                {
                    return 0;
                }
            }
            set{;}
        }
        [DataMember]
        public List<PaperFaceDCT> AllFace { get; set; }
        [DataMember]
        public List<PaperTypeDCT> AllType { get; set; }
        [DataMember]
        public List<PrinterDCT> AllPrint { get; set; }
        [DataMember]
        public PaperFaceDCT PaperFace { get; set; }
        [DataMember]
        public PaperTypeDCT PaperTypeInfo { get; set; }
        [DataMember]
        public PrinterDCT PrintInfo { get; set; }
        
        private string _printName;
        [DataMember]
        public string PrintName
        {
            get {
                if (PrintInfo != null)
                {
                    return PrintInfo.PName;
                }
                else
                {
                    return "";
                }
            }

            set
            {
                _printName = value;
                if (!string.IsNullOrEmpty(value))
                {
                    PrintInfo = AllPrint.FirstOrDefault(p => p.PName == value);
                }
            }
        }

        private string _paperFaceName;
        [DataMember]
        public string PaperFaceName
        {
            get
            {
                if (PaperFace != null)
                {
                    return PaperFace.PaperFaceName;
                }
                else
                {
                    return "";
                }
            }
            set
            {
                _paperFaceName = value;
                if (!string.IsNullOrEmpty(value))
                PaperFace = AllFace.FirstOrDefault(p => p.PaperFaceName == value);
            }
        }

        private string _paperTypeName;
        [DataMember]
        public string PaperTypeName
        {
            get
            {
                if (PaperTypeInfo != null)
                {
                    return PaperTypeInfo.PaperTypeName;
                }
                else
                {
                    return "";
                }
            }
            set
            {
                _paperTypeName = value;
                if (!string.IsNullOrEmpty(value))
                PaperTypeInfo = AllType.FirstOrDefault(p => p.PaperTypeName == value);
            }
        }
        [DataMember]
        public string OrilOrderPath
        { get; set; }
        [DataMember]
        public string MoveStatus { get; set; }
        [DataMember]
        public int DPI
        {
            get
            {
                if (PhotoS.GroupBy(p => p.DPI).Count() > 1)
                {
                    return 0;
                }
                else
                {
                    if (PhotoS.Count() > 0)
                    {
                        return PhotoS.FirstOrDefault().DPI;
                    }
                    else
                    {
                        return 0;
                    }
                }
            }
            set { }
        }
        #endregion

        #region 公开属性
        [DataMember]
        public int OrderProductId
        {
            get { return _orderProductId; }
            set { _orderProductId = value; }
        }
        [DataMember]
        public string OrderName
        {
            get { return _orderName; }
            set { _orderName = value; }
        }
        [DataMember]
        public DateTime StartTime
        {
            get { return _startTime; }
            set { _startTime = value; }
        }
        [DataMember]
        public DateTime CompleteTime
        {
            get { return _completeTime; }
            set { _completeTime = value; }
        }
        [DataMember]
        public int Status
        {
            get { return _status; }
            set { _status = value; }
        }
        [DataMember]
        public string OrderPath
        {
            get { return _orderPath; }
            set { _orderPath = value; }
        }
        [DataMember]
        public string Remark
        {
            get { return _remark; }
            set { _remark = value; }
        }
        [DataMember]
        public int ProductNum
        {
            get { return _productNum; }
            set { _productNum = value; }
        }
        [DataMember]
        public int Priority
        {
            get { return _priority; }
            set { _priority = value; }
        }
        [DataMember]
        public int SameFlagOrderId
        {
            get { return _sameFlagOrderId; }
            set { _sameFlagOrderId = value; }
        }
        [DataMember]
        public string FatherFolder { get; set; }
        [DataMember]
        public string GranddadFolder { get; set; }
        #endregion
    }
}
